<?php
require('../database/db.php');
$mysql=new mysql();
$shopid=$_REQUEST[shopid];
if ($shopid) {
	// 查询shop表的open值
	$sql = "select open from shop where shopid = ".$shopid;
	$open = $mysql->getOne($sql);
	if ($open==0) {
		$newOpen=1;
	}else{
		$newOpen=0;
	}
	// 查询shop表的open值 end
	$sql="UPDATE shop set open =".$newOpen." where shopid=".$shopid;
	$mysql->query($sql);
	if ($mysql->affected_rows()>0) {
		if ($open==0) {
			$arr = array('code' => 100, 'tip' =>'开业成功');
		}else{
			$arr = array('code' => 101, 'tip' =>'闭业成功');
		}
	}else{
		$arr = array('code' => 300, 'tip' =>'操作失败');
	}
}else{
	$arr = array('code' => 200, 'tip' =>'参数传入有误,营业与否=>open');
}
echo json_encode($arr);
?>